package demoxsgl_300.com.gouwu1500.zhi;

import android.Manifest;
import android.app.Activity;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import demoxsgl_300.com.gouwu1500.R;
import demoxsgl_300.com.gouwu1500.certificateCamera.CameraActivity;


public class MainActivity extends Activity {

    @BindView(R.id.tv_login)
    TextView tvLogin;
    @BindView(R.id.tv_logout)
    TextView tvLogout;
    @BindView(R.id.textView5)
    TextView textView5;
    @BindView(R.id.textView6)
    TextView textView6;
    @BindView(R.id.kaishiwenzhen)
    Button kaishiwenzhen;
    @BindView(R.id.jiankangdangan)
    Button jiankangdangan;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_test);
        ButterKnife.bind(this);
    }

    @Override
    protected void onResume() {
        super.onResume();
        if (!Content.user_password.equals("")) {
            tvLogin.setText(Content.user_password);
        } else {
            tvLogin.setText("登录");
        }
    }

    @OnClick({R.id.tv_login, R.id.tv_logout, R.id.kaishiwenzhen, R.id.jiankangdangan})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.tv_login:
                if (!Content.user_password.equals("")) {
                    Toast.makeText(this, "您已登录，请先注销!", Toast.LENGTH_SHORT).show();
                } else {
                    startActivity(new Intent(this, LoginActivity.class));
                }

                break;

            case R.id.tv_logout:
                Content.Login = false;
                Content.user_password = "";
                tvLogin.setText("登录");
                Toast.makeText(this, "注销成功！", Toast.LENGTH_SHORT).show();
                break;
            case R.id.kaishiwenzhen:
                startActivity(new Intent(this, GeRenActivity.class));

//                startActivity(new Intent(this, XuanZeActivity.class));
                break;
            case R.id.jiankangdangan:
                if (Content.Login == false) {
                    Toast.makeText(this, "请先登录！", Toast.LENGTH_SHORT).show();

                } else {
                    startActivity(new Intent(this, JianKangDangAnActivity.class));
                }

                break;
        }
    }


}
